package hr.fer.pus.dll_will.cr.actions;

import java.io.IOException;
import java.net.URLDecoder;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;

import hr.fer.pus.dll_will.cr.IActionHandler;

/**
 * Simple action handler.
 * Writes text given in parameter {@code text} to output stream.
 *
 */
public class SimplePrint implements IActionHandler {

	@Override
	public boolean performAction(ServletOutputStream out,
			HttpServletRequest request) throws IOException {
		
		String text = (String) request.getParameter("text");
		if (text == null) return false;
		
		text = URLDecoder.decode(text, "UTF-8");
		out.write(text.getBytes("UTF-8"));
		
		return true;
	}

}
